<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="../react18/react.development.js"></script>
    <script src="../react18/react-dom.development.js"></script>
    <script src="../react18/babel.min.js"></script>
</head>
<body>
    <div id="app"></div>
    <script type="text/babel">
           class MySelf extends React.Component {
        render() {
          console.log(this);
          const {name,age,sex}=this.props.item;
          return (
            <div>
              <h2>我的名字是{name + "~"}</h2>
              <h2>我的年龄是{age}</h2>
              <h2>我的性别是{sex}</h2>
            </div>
          );
        }
      }
      class App extends React.Component {
        state = {
          students: [
            { id: 1, name: "张三", age: 18, sex: "男" },
            { id: 2, name: "李四", age: 20, sex: "女" },
            { id: 3, name: "王五", age: 12, sex: "女" },
          ],
        };
        render() {
            const {students} = this.state;
          return (
          <ul>
            {students.map(item=>{
                return <li>
                    <h2>{item.name}自我介绍</h2>
                    <MySelf item={item}/>
                    {/* <MySelf {...item}/> */}
                    </li>
            })}
            </ul>
          );
        }
      }
      ReactDOM.createRoot(document.getElementById("app")).render(<App />);
    </script>
</body>
</html>